package com.longcai.piaojia.widget;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zcx.helper.view.asy.AsyViewLayout;

/**
 * Created by Administrator on 2016/9/9.
 */
public class LoadUsefulView extends AsyViewLayout {

    public LoadUsefulView(Context c, AttributeSet t) {
        super(c, t);
    }

    @Override
    protected ViewGroup onCreateRefresh(LayoutInflater layoutInflater) {

        TextView view = new TextView(this.getContext());
        view.setLayoutParams(new LayoutParams(-1, -1));
        view.setText("网络连接异常\n\n请点击重新加载");
        view.setGravity(17);
        view.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                LoadUsefulView.this.refresh();
            }
        });

        RelativeLayout relativeLayout = new RelativeLayout(this.getContext());
        relativeLayout.setLayoutParams(new LayoutParams(-1, -1));
        relativeLayout.setBackgroundColor(Color.parseColor("#ffffff"));
        relativeLayout.setGravity(17);
        relativeLayout.addView(view);

        relativeLayout.setClickable(true);

        return relativeLayout;
    }

    @Override
    protected ViewGroup onCreateUpload(LayoutInflater layoutInflater) {
        TextView view = new TextView(this.getContext());
        view.setLayoutParams(new LayoutParams(-1, -2));
        view.setGravity(17);
        view.setText("正在加载数据请稍等……");

        RelativeLayout relativeLayout = new RelativeLayout(this.getContext());
        relativeLayout.setLayoutParams(new LayoutParams(-1, -1));
        relativeLayout.setBackgroundColor(Color.parseColor("#ffffff"));
        relativeLayout.setGravity(17);
        relativeLayout.addView(view);

        relativeLayout.setClickable(true);

        return relativeLayout;
    }

    @Override
    protected ViewGroup onCreateNothing(LayoutInflater layoutInflater) {
        TextView view = new TextView(this.getContext());
        view.setLayoutParams(new LayoutParams(-1, -1));
        view.setGravity(17);
        view.setText("暂无数据");
        RelativeLayout relativeLayout = new RelativeLayout(this.getContext());
        relativeLayout.setLayoutParams(new LayoutParams(-1, -1));
        relativeLayout.setBackgroundColor(Color.parseColor("#ffffff"));
        relativeLayout.setGravity(17);
        relativeLayout.addView(view);

        relativeLayout.setClickable(true);

        return relativeLayout;
    }
}
